package cn.xicode.cloud.frame.dubbo.consumer.user;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author LGC
 */
@Slf4j
@RestController
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/username")
    public String getUsername() {
        String username = userService.getUsername();
        String aa = RpcContext.getServerContext().getAttachment("aa");
        log.info("消费端获取服务端值aa:{}", aa);

        String cc = RpcContext.getServerContext().getAttachment("cc");
        log.info("消费端获取服务端值cc：{}", cc);
        return username;
    }
}
